<?php

namespace app\topics\controller;

class FaqCreateController extends \app\topics\controller\TopicsController {

    protected $_middle = 'topics/FaqCreate';

    public function index() {
        if(!isPost()) {
            target($this->_middle, 'middle')->meta()->data()->export(function ($data) {
                $this->assign($data);
                $this->topicsDisplay();
            }, function ($message, $code, $url) {
                $this->errorCallback($message, $code, $url);
            });
        }else {
            target($this->_middle, 'middle')->setParams([
                'data' => request('post'),
                'user_id' => $this->userInfo['user_id']
            ])->post()->export(function ($data, $msg) {
                $this->success($msg, url('topics/Faq/info', ['id' => $data['id']]));
            }, function ($message, $code, $url) {
                $this->errorCallback($message, $code, $url);
            });
        }
    }

}